import React from 'react'
import { Table } from 'antd';
import { getMsgData } from '../../config/api'
import { Httpget } from '../../config/request'
import PanelBox from '../../components/PanelBox';
import moment from 'moment'

const columns = [{
  title: '内容',
  dataIndex: 'des',
  width: '90%',
}, {
  title: '发送时间',
  dataIndex: 'sendTime',
  width: '10%',
}];

export default class MailboxPage extends React.Component {
  constructor(porps) {
    super(porps)
    this.state = {
      data: [],
      columns: columns
    }
  }
  componentDidMount() {
    this.initMsgData()
  }
  initMsgData() {
    Httpget(getMsgData).then((res) => {
      if (res.data) {
        let data =res.data
        for(let i=0;i<data.length;i++){
          data[i].sendTime = moment(data[i].sendTime).format('YYYY-MM-DD');
        }
        this.setState({
          data
        })
      }
    }).catch((res) => {

    })

  }
  render() {
    return (
      <PanelBox title="Mailbox Page">
        <Table columns={columns} dataSource={this.state.data} size="small" />
      </PanelBox>
    );
  }
}

